package edu.xhu.biliuser.controller;

import edu.xhu.model.biliuser.dtos.LoginAndRegisterDto;
import edu.xhu.model.common.dtos.ResponseResult;
import edu.xhu.biliuser.service.BiliUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

@Api(value = "网页端用户Controller层", tags = "网页端用户Controller层")
@CrossOrigin
@RestController
@RequiredArgsConstructor
@RequestMapping("/biliuser")
public class BiliUserController {
 
    private final BiliUserService biliUserService;

    @PostMapping("/login_auth")
    @ApiOperation("bili主页用户登录")
    public ResponseResult<?> login(@RequestBody LoginAndRegisterDto dto) {
        return biliUserService.login(dto);
    }

    @PostMapping("/register")
    @ApiOperation("bili主页用户注册")
    public ResponseResult<?> register(@RequestBody LoginAndRegisterDto dto) {
        return biliUserService.register(dto);
    }

    @GetMapping("/info")
    @ApiOperation("bili主页用户信息")
    public ResponseResult<?> info() {
        return biliUserService.personalInfo();
    }

    @GetMapping("/info/get-one")
    @ApiOperation("bili空间用户信息")
    public ResponseResult<?> oneInfo(@RequestParam("uid") Long uid) {
        return biliUserService.onepersonalInfo(uid);
    }

    @GetMapping("/logout")
    @ApiOperation("bili主页用户退出")
    public void logout() {
        biliUserService.logout();
    }
}
